package com.symria.system.convert;


import java.util.Map;

import org.apache.struts2.util.StrutsTypeConverter;

import com.symria.framework.util.StringUtil;


public class DoubleConvert extends StrutsTypeConverter {



    @Override  
    public Object convertFromString(Map context, String[] values, Class toClass) {  
        if (Double.class == toClass) {
            String doubleStr = values[0];              
           if(!StringUtil.isEmpty(doubleStr)) {
        	   try{
            	   Double d = Double.parseDouble(doubleStr);  
            	   return d;  
        	   }catch(Exception e){
        		   return null;
        	   }
           }
        }  
        return null;  
    }  
  
    @Override  
    public String convertToString(Map context, Object o) {   
        return o.toString();  
    }  



}
